﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Eis51.CampanyCMS.Business;
using Eis51.CampanyCMS.Business.Bus;
 
using System.Text;
using Eis51.CampanyCMS.Model;
using Eis51.CampanyCMS.Model.Bus;
using Eis51.BuildingHtml;
using Eis51.Web.Admin;

namespace Eis51.CampanyCMS.UI.Admin.SystemManager
{
    public partial class HtmlEdit : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                IniData();
            }
        }

        private void IniData()
        {
        //    if (AppContext.CurrentAdministrator == null) return;
        //    string path = @"~/{0}/xml/CallMethodArrMod.xml";
        //    path = string.Format(path, "index" + AppContext.GetCurrentName());
        //    DataTable dt = BuildPageBLL.GetHtmlPath(path);
        //    dlistHtmlpath.DataTextField = "name";
        //    dlistHtmlpath.DataValueField = "keyvalue";
        //    dlistHtmlpath.DataSource = dt;
        //    dlistHtmlpath.DataBind();
        //    dlistHtmlpath.Items.Insert(0, new ListItem("请选择", ""));
        
        }

        protected void dlistHtmlpath_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (dlistHtmlpath.SelectedValue == null || dlistHtmlpath.SelectedValue == string.Empty) return;
            txtcontent.Value=  BuildCommon.GetHTML(dlistHtmlpath.SelectedValue);
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (dlist.SelectedValue == "U8")
            {
                //AppContext.CurrentEncoding = Encoding.UTF8;
            }
            else
            {
                //AppContext.CurrentEncoding = Encoding.GetEncoding("gb2312");
            }
            string strText ="   "+ txtcontent.Value;
            BuildCommon.BakuFile(dlistHtmlpath.SelectedValue);
            BuildCommon.CreaetHTMLFile(dlistHtmlpath.SelectedValue, strText);

        }
    }
}
